webpackJsonphippius([2],{

/***/ 176:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_Scroll_vue__ = __webpack_require__(496);
/* empty harmony namespace reexport */
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_157c1923_hasScoped_true_transformToRequire_video_src_poster_source_src_img_src_image_xlink_href_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_Scroll_vue__ = __webpack_require__(525);
function injectStyle (ssrContext) {
  __webpack_require__(523)
}
var normalizeComponent = __webpack_require__(5)
/* script */


/* template */

/* template functional */
var __vue_template_functional__ = false
/* styles */
var __vue_styles__ = injectStyle
/* scopeId */
var __vue_scopeId__ = "data-v-157c1923"
/* moduleIdentifier (server only) */
var __vue_module_identifier__ = null
var Component = normalizeComponent(
  __WEBPACK_IMPORTED_MODULE_0__babel_loader_node_modules_vue_loader_lib_selector_type_script_index_0_Scroll_vue__["a" /* default */],
  __WEBPACK_IMPORTED_MODULE_1__node_modules_vue_loader_lib_template_compiler_index_id_data_v_157c1923_hasScoped_true_transformToRequire_video_src_poster_source_src_img_src_image_xlink_href_buble_transforms_node_modules_vue_loader_lib_selector_type_template_index_0_Scroll_vue__["a" /* default */],
  __vue_template_functional__,
  __vue_styles__,
  __vue_scopeId__,
  __vue_module_identifier__
)

/* harmony default export */ __webpack_exports__["default"] = (Component.exports);


/***/ }),

/***/ 496:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0____ = __webpack_require__(162);
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__utils_util__ = __webpack_require__(524);
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

//
//
//
//
//
//
//
//
//
//
//
//
//
//




/* harmony default export */ __webpack_exports__["a"] = ({
  name: 'App',
  components: {
    Scroll: __WEBPACK_IMPORTED_MODULE_0____["o" /* Scroll */]
  },
  data: function data() {
    return {
      list: [],
      page: 1,
      pageSize: 10
    };
  },
  mounted: function mounted() {
    this.loadRefresh();
  },

  methods: {
    // 滚动到顶部
    scrollToTop: function scrollToTop() {
      this.$refs.scroll.scrollTo(0, 0);
    },

    // 加载刷新数据
    loadRefresh: function loadRefresh() {
      var _this = this;

      return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
        var data;
        return regeneratorRuntime.wrap(function _callee$(_context) {
          while (1) {
            switch (_context.prev = _context.next) {
              case 0:
                _context.next = 2;
                return _this._fetchList();

              case 2:
                data = _context.sent;


                // 初始化数据
                _this.list = data;
                _this.page = 1;

              case 5:
              case 'end':
                return _context.stop();
            }
          }
        }, _callee, _this);
      }))();
    },

    // 加载更多数据
    loadMore: function loadMore() {
      var _this2 = this;

      return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
        var _list;

        var page, data;
        return regeneratorRuntime.wrap(function _callee2$(_context2) {
          while (1) {
            switch (_context2.prev = _context2.next) {
              case 0:
                page = _this2.page + 1;
                _context2.next = 3;
                return _this2._fetchList(page);

              case 3:
                data = _context2.sent;


                (_list = _this2.list).push.apply(_list, _toConsumableArray(data));
                data.length < _this2.pageSize ? _this2.$refs.scroll.update(true) : _this2.page++; // 判断是否已达最后一页?如果已是最后一页，可调用this.$refs.scroll.update(true)声明已是最后一页。下拉刷新后该值会自动false，也可调用 this.$refs.scroll.update(false) 手动声明不是最后一页

              case 6:
              case 'end':
                return _context2.stop();
            }
          }
        }, _callee2, _this2);
      }))();
    },


    // 模拟一个异步获取列表操作
    _fetchList: function _fetchList() {
      var _this3 = this;

      var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
      var pageSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.pageSize;
      return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
        return regeneratorRuntime.wrap(function _callee3$(_context3) {
          while (1) {
            switch (_context3.prev = _context3.next) {
              case 0:
                _context3.prev = 0;
                _context3.next = 3;
                return Object(__WEBPACK_IMPORTED_MODULE_1__utils_util__["a" /* timeout */])(1000);

              case 3:
                if (!(page < 3)) {
                  _context3.next = 7;
                  break;
                }

                return _context3.abrupt('return', Array.from({ length: pageSize }, function (value, index) {
                  return '\u7B2C' + page + '\u9875\u7684\u6570\u636E' + index;
                }));

              case 7:
                return _context3.abrupt('return', Array.from({ length: pageSize / 2 }, function (value, index) {
                  return '\u6700\u540E\u4E00\u9875,\u7B2C' + page + '\u9875\u7684\u6570\u636E' + index;
                }));

              case 8:
                _context3.next = 13;
                break;

              case 10:
                _context3.prev = 10;
                _context3.t0 = _context3['catch'](0);
                return _context3.abrupt('return', false);

              case 13:
              case 'end':
                return _context3.stop();
            }
          }
        }, _callee3, _this3, [[0, 10]]);
      }))();
    }
  }
});

/***/ }),

/***/ 523:
/***/ (function(module, exports) {

// removed by extract-text-webpack-plugin

/***/ }),

/***/ 524:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (immutable) */ __webpack_exports__["a"] = timeout;
/* unused harmony export assert */
/* unused harmony export case2Param */
/**
 * 一些帮助函数
 */

/**
 * setTimeout 的 promise 封装
 * @param {Number} time
 * @returns
 */
function timeout(time) {
  return new Promise(function (resolve) {
    setTimeout(resolve, time);
  });
}

/**
 * 断言
 * @param {any} condition 条件
 * @param {any} msg 信息
 */
function assert(condition, msg) {
  if (!condition) throw new Error('[hips] ' + msg);
}

/**
 * 改变 case 格式为 param
 * @param {String} str 字符串
 */
function case2Param(str) {
  assert(typeof str === 'string', 'case2Param 传入数据类型错误：应为 String');

  str = str.replace(/^[A-Z]/g, function ($0) {
    return $0.toLowerCase();
  });
  return str.replace(/[A-Z]/g, function ($0) {
    return '-' + $0.toLowerCase();
  });
}

/***/ }),

/***/ 525:
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('Scroll',{ref:"scroll",attrs:{"updateData":[_vm.list],"refreshData":[]},on:{"pullingDown":_vm.loadRefresh,"pullingUp":_vm.loadMore}},[_c('ul',[_vm._l((_vm.list),function(item,index){return _c('li',{key:index},[_vm._v(_vm._s(item))])}),_vm._v(" "),_c('li',{directives:[{name:"show",rawName:"v-show",value:(_vm.list.length > 20),expression:"list.length > 20"}],staticStyle:{"color":"#1F8CEB"},on:{"click":_vm.scrollToTop}},[_vm._v("点我回到顶部")])],2)])}
var staticRenderFns = []
var esExports = { render: render, staticRenderFns: staticRenderFns }
/* harmony default export */ __webpack_exports__["a"] = (esExports);

/***/ })

});